package net.adetech.utils;

import java.io.InputStream;
import java.util.Map;
import java.util.Properties;

public final class UtilsProperties extends Properties {
    private static UtilsProperties env;

    public static UtilsProperties getInstance() {
        if (env != null) {
            return env;
        } else {
            makeInstance();
            return env;
        }
    }

    public void load(String key, String value) {
        env.put(key, value);
    }

    public void loadAll(Map<String, String> map) {
        env.putAll(map);
    }


    private static synchronized void makeInstance() {
        if (env == null) {
            env = new UtilsProperties();
        }
    }

    private UtilsProperties() {
        InputStream is = this.getClass().getResourceAsStream("/sys.properties");
        try {
            this.load(is);
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
